<?php

class Controller extends Smarty
{
    public function __construct()
    {
        $this->setTemplateDir('./views')
            ->setCompileDir('./runtime/views_c')
            ->setConfigDir('./configs')
            ->setCacheDir('./runtime/caches');
        // 配置 模板变量的定界符 {{ }}
        $this->left_delimiter = LEFT_D;
        $this->right_delimiter = RIGHT_D;
        // 配置 缓存控制 (开启缓存/缓存时间)
        $this->caching = CACHING; // 开启
        $this->cache_lifetime = CLT; // 缓存30s
    }

    public function redirect($msg, $url = null)
    {
        echo "<script>alert('{$msg}');</script>";
        if (empty($url)) {
            echo "<script>history.back()</script>";
        } else {
            echo "<script>location.href = '{$url}'</script>";
        }
    }

    public function __call($name, $arguments)
    {
        header('HTTP/1.0 404 not found');
        echo '<h1>404 NOT FOUND-基类</h1>';
        exit;
    }

}